<?php


get_header(); ?>


<script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/js/mousescroll.js">    </script>

<link href="<?php echo get_template_directory_uri(); ?>/css/app-store.css" rel="stylesheet" type="text/css" />
<?php if (is_home()) { echo "Home page here"; }?>

<div id="GlobalContainer" class="row" role="main">
<div id="MainContainer" class="twelve columns">
<section id="MainContent" class="box">
<div id="TilesCategories">

<section class="tilesCategory">
<div class="category">
<?php  query_posts('cat=1'); $counter2=1; $lastcat1=0; $limitpost=1;
if(is_category(1)) :   $categories = get_categories('child_of=1');
    foreach ($categories as $cat){ $lastcat1++  ;} ?>
        <?php endif; ?>

    <div id="category1">
        <h3 class="titlecategory">Lịch hội thảo – khóa học</h3>
        <?php if(is_category(1)) :   $categories = get_categories('child_of=1'); $countorder = 1;
            foreach ($categories as $cat): ?>


<?php if($countorder==1): ?>
        <div class="fisrtfeaturetext">
            <div class="featuresimage">
                <img src="<?php if(function_exists('z_taxonomy_image_url')){echo z_taxonomy_image_url($cat->term_id);} ?>" alt="featureimage" width="380" height="380">
            </div>
            <a href="<?php echo home_url(); ?>/category/lich-hoi-thao-khoa-hoc/<?php echo $cat->category_nicename; ?>">
                <div class="wrapcontent">
                    <div class="shortcontent">
                        <h3 class="tileposts"> <?php echo $cat->cat_name; ?></h3>
                        <div class="newstext">
                            <?php echo substr(strip_tags(category_description($cat->cat_ID)),0, 100); ?>
                        </div>
                    </div>

                </div>
            </a>
            <a href="<?php echo home_url(); ?>/category/lich-hoi-thao-khoa-hoc/<?php echo $cat->category_nicename; ?>">
                <div class="wrapcontent2" style="display: none;">
                    <h3 class="tileposts"> <?php echo $cat->cat_name; ?> </h3>
                    <div class="longcontent">
                        <?php echo category_description($cat->cat_ID); ?>
                    </div>
                </div>
            </a>
        </div>

<?php $countorder++ ; else : ?>
                    <?php if($countorder==2):  ?>
        <div class="wrapallsecond">
            <div class="slidehover2">
            <ul class="allcontentfeature">
                <?php endif; ?>
            <li><a href="<?php echo home_url(); ?>/category/lich-hoi-thao-khoa-hoc/<?php echo $cat->category_nicename; ?>">
                <div class="secondfeaturetext">
                    <div class="newsimage">
                        <img src="<?php if(function_exists('z_taxonomy_image_url')){echo z_taxonomy_image_url($cat->term_id);} ?>" width="185" height="185" alt="featureimage">
                    </div>
                    <div class="wrapcontent">
                        <h3 class="tileposts"> <?php echo $cat->cat_name; ?> </h3>
                            <div class="newstext"><?php echo substr(strip_tags(category_description($cat->cat_ID)),0, 100); ?> </div>
                       </div>
                    <div class="wrapcontent2" style="display: none;">
                        <h3 class="tileposts"> <?php echo $cat->cat_name; ?> </h3>
                        <div class="newstext"> <?php echo category_description($cat->cat_ID); ?></div>
                    </div>
                </div>
                </a>
            </li>
<?php $countorder++; if($countorder==($lastcat1+1)): ?>
            </ul>

            </div>
        </div>
 <?php endif; ?>
<?php endif; ?>
            <?php endforeach; ?>
        <?php endif; ?>


    </div>
</div>
</section>
<section class="tilesCategory">
<div class="category">
    <?php  query_posts('cat=4'); $counter2=1; $last3=0;  $limitpost=1;
    while (have_posts()) : the_post();  ?>
        <?php $last3++;  endwhile;  ?>

    <div id="category2">
        <h3 class="titlecategory">Tin tức – Hoạt động</h3>
        <?php
        $totalnewspost2 = category_post_count('4');
        $max_num_post2 = get_option('posts_per_page');
        $number_of_page2 = round($totalnewspost2 / $max_num_post2);
        $number_of_last_post2 = $totalnewspost2 % $max_num_post2;
        ?>
        <?php  $additionloop2 = new WP_Query("cat=4 & paged=$paged");
        $featureoddeven = 1; $counter2=1;
        while ($additionloop2->have_posts()) : $additionloop2->the_post();
            ?>
            <?php if($counter2==1): ?>
                <div class="fisrtfeaturetext">
                    <div class="featuresimage"><?php $feat_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>
                        <img src="<?php echo $feat_image ?>" alt="featureimage" width="380" height="380" />


                    </div>
                    <a href="<?php the_permalink(); ?>">
                        <div class="wrapcontent">
                            <div class="shortcontent">
                                <h3 class="tileposts"><?php the_title(); ?></h3>
                                <div class="newstext">
                                    <?php  $arraytext = apply_filters('the_content', substr(get_the_content(), 0, 300) ); echo strip_tags($arraytext); ?>
                                </div>
                            </div>

                        </div>
                    </a>
                    <a href="<?php the_permalink(); ?>">
                        <div class="wrapcontent2">
                            <h3 class="tileposts"><?php the_title(); ?></h3>
                            <div class="longcontent">
                                <?php  $arraytext = apply_filters('the_content', (get_the_content()) ); echo strip_tags($arraytext); ?>
                            </div>
                        </div>
                    </a>
                </div>
                <?php  $counter2++; ?>


            <?php else: ?>
                <?php if($counter2==2) : ?>

                    <div class="wrapallsecond">
                    <div class="slidehover2">
                    <ul class="allcontentfeature">
                <?php endif; ?>
                <?php if($featureoddeven%2==1): ?>
                <li>
            <?php endif; ?>
                <a href="<?php the_permalink(); ?>">
                    <div class="secondfeaturetext">
                        <div class="newsimage"><?php $feat_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>
                            <img src="<?php echo $feat_image ?>" width="185" height="185" alt="featureimage" />

                        </div>
                        <div class="wrapcontent">
                            <h3 class="tileposts"><?php the_title(); ?></h3>
                            <div class="newstext">
                                <?php  $arraytext = apply_filters('the_content', substr(get_the_content(), 0, 100) ); echo strip_tags($arraytext) ?>
                            </div></div>
                        <div class="wrapcontent2">
                            <h3 class="tileposts"><?php the_title(); ?></h3>
                            <div class="newstext">
                                <?php  $arraytext = apply_filters('the_content', get_the_content() ); echo strip_tags($arraytext) ?>
                            </div></div>
                    </div>
                </a>
                <?php if($featureoddeven % 2 == 0  || $counter2==$last3+1): ?>
                </li>
            <?php endif; ?>

                <?php $featureoddeven++ ; $counter2++; $lastitem3 = $last3+1 ;  ?>
                <?php if(($counter2 == $lastitem3) ): ?>
                    </ul>
                    </div>
                    </div>
                <?php endif; ?>
            <?php endif; ?>

        <?php endwhile;       ?>
    </div>
</div>
</section>
<section class="tilesCategory">
<div class="category">
    <?php  query_posts('cat=3'); $counter2=1; $last3=0;  $limitpost=1;
    while (have_posts()) : the_post();  ?>
        <?php $last3++;  endwhile;  ?>

    <div id="category3">
        <h3 class="titlecategory overflowclear">Nhân Vật – Sự Kiện</h3>
        <?php
        $totalnewspost2 = category_post_count('3');
        $max_num_post2 = get_option('posts_per_page');
        $number_of_page2 = round($totalnewspost2 / $max_num_post2);
        $number_of_last_post2 = $totalnewspost2 % $max_num_post2;
        ?>
        <?php  $additionloop2 = new WP_Query("cat=3 & paged=$paged");
        $featureoddeven = 1; $counter2=1;
        while ($additionloop2->have_posts()) : $additionloop2->the_post();
            ?>
            <?php if($counter2==1): ?>
                <div class="fisrtfeaturetext">
                    <div class="featuresimage"><?php $feat_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>
                        <img src="<?php echo $feat_image ?>" alt="featureimage" width="380" height="380" />


                    </div>
                    <a href="<?php the_permalink(); ?>">
                        <div class="wrapcontent">
                            <div class="shortcontent">
                                <h3 class="tileposts"><?php the_title(); ?></h3>
                                <div class="newstext">
                                    <?php  $arraytext = apply_filters('the_content', substr(get_the_content(), 0, 300) ); echo strip_tags($arraytext); ?>
                                </div>
                            </div>

                        </div>
                    </a>
                    <a href="<?php the_permalink(); ?>">
                        <div class="wrapcontent2">
                            <h3 class="tileposts"><?php the_title(); ?></h3>
                            <div class="longcontent">
                                <?php  $arraytext = apply_filters('the_content', (get_the_content()) ); echo strip_tags($arraytext); ?>
                            </div>
                        </div>
                    </a>
                </div>
                <?php  $counter2++; ?>


            <?php else: ?>
                <?php if($counter2==2) : ?>

                    <div class="wrapallsecond">
                    <div class="slidehover2">
                    <ul class="allcontentfeature">
                <?php endif; ?>
                <?php if($featureoddeven%2==1): ?>
                <li>
            <?php endif; ?>
                <a href="<?php the_permalink(); ?>">
                    <div class="secondfeaturetext">
                        <div class="newsimage"><?php $feat_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>
                            <img src="<?php echo $feat_image ?>" width="185" height="185" alt="featureimage" />

                        </div>
                        <div class="wrapcontent">
                            <h3 class="tileposts"><?php the_title(); ?></h3>
                            <div class="newstext">
                                <?php  $arraytext = apply_filters('the_content', substr(get_the_content(), 0, 100) ); echo strip_tags($arraytext) ?>
                            </div></div>
                        <div class="wrapcontent2">
                            <h3 class="tileposts"><?php the_title(); ?></h3>
                            <div class="newstext">
                                <?php  $arraytext = apply_filters('the_content', get_the_content() ); echo strip_tags($arraytext) ?>
                            </div></div>
                    </div>
                </a>
                <?php if($featureoddeven % 2 == 0  || $counter2==$last3+1): ?>
                </li>
            <?php endif; ?>

                <?php $featureoddeven++ ; $counter2++; $lastitem3 = $last3+1 ;  ?>
                <?php if(($counter2 == $lastitem3) ): ?>
                    </ul>
                    </div>
                    </div>
                <?php endif; ?>
            <?php endif; ?>

        <?php   endwhile;       ?>
    </div>
</div>
</section>
</div>
</section>
</div></div>


<?php //get_sidebar(); ?>
<?php get_footer(); ?>